# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

    def forwards(self, orm):
        # Adding model 'tag'
        db.create_table('poster_tag', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=30)),
        ))
        db.send_create_signal('poster', ['tag'])

        # Adding model 'blog'
        db.create_table('poster_blog', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('author', self.gf('django.db.models.fields.CharField')(max_length=12)),
            ('title', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('create_time', self.gf('django.db.models.fields.DateTimeField')()),
            ('content', self.gf('django.db.models.fields.TextField')()),
        ))
        db.send_create_signal('poster', ['blog'])

        # Adding M2M table for field tags on 'blog'
        m2m_table_name = db.shorten_name('poster_blog_tags')
        db.create_table(m2m_table_name, (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('blog', models.ForeignKey(orm['poster.blog'], null=False)),
            ('tag', models.ForeignKey(orm['poster.tag'], null=False))
        ))
        db.create_unique(m2m_table_name, ['blog_id', 'tag_id'])


    def backwards(self, orm):
        # Deleting model 'tag'
        db.delete_table('poster_tag')

        # Deleting model 'blog'
        db.delete_table('poster_blog')

        # Removing M2M table for field tags on 'blog'
        db.delete_table(db.shorten_name('poster_blog_tags'))


    models = {
        'poster.blog': {
            'Meta': {'object_name': 'blog'},
            'author': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
            'content': ('django.db.models.fields.TextField', [], {}),
            'create_time': ('django.db.models.fields.DateTimeField', [], {}),
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['poster.tag']", 'symmetrical': 'False'}),
            'title': ('django.db.models.fields.CharField', [], {'max_length': '100'})
        },
        'poster.tag': {
            'Meta': {'object_name': 'tag'},
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '30'})
        }
    }

    complete_apps = ['poster']